package com.sunshine.wrongquestionset.view

import android.content.Context
import android.view.View
import androidx.annotation.StyleRes
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog

/**
 * @author sunshine
 * @date 2021/4/19
 */
class ScrollBottomSheetDialog(context: Context, @StyleRes style: Int) : BottomSheetDialog(context, style) {
    private var bottomSheetBehavior: BottomSheetBehavior<View>? = null

    private val mBottomSheetCallback: BottomSheetBehavior.BottomSheetCallback = object : BottomSheetBehavior.BottomSheetCallback() {
        override fun onSlide(bottomSheet: View, slideOffset: Float) {

        }

        override fun onStateChanged(bottomSheet: View, newState: Int) {
            if (newState == BottomSheetBehavior.STATE_DRAGGING) { //判断为向下拖动行为时，则强制设定状态为展开

            }
            //bottomSheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
        }
    }

    fun setBottomSheetCallback(sheetView: View) {
        if (bottomSheetBehavior == null) {
            bottomSheetBehavior = BottomSheetBehavior.from(sheetView)
        }
        bottomSheetBehavior!!.addBottomSheetCallback(mBottomSheetCallback)
    }
}